<template>
  <el-row class="utlis">
    <div>
      <el-radio-group v-model="radio" @change="selectType">
        <el-radio :label="3">全部</el-radio>
        <el-radio :label="0">待就诊</el-radio>
        <el-radio :label="1">已就诊</el-radio>
        <el-radio :label="2">已取消</el-radio>
      </el-radio-group>
    </div>
    <div>
      <el-date-picker
        v-model="value1"
        type="daterange"
        range-separator="~"
        start-placeholder="请选择开始日期"
        end-placeholder="请选择结束日期"
        @change="selectDate"
      />
      <el-cascader
        v-model="select"
        :options="options"
        class="thead-utils"
        clearable
        @change="changeVal"
        placeholder="请选择科室"
      />
      <el-input v-model="input" placeholder="请输入患者姓名" /><el-button
        type="primary"
        @click="seachys"
        >搜索</el-button
      >
      <el-button type="primary" @click="resetSH">重置</el-button>
    </div>
  </el-row>
</template>
<script>
import { ref, reactive, toRefs, computed, watch } from "vue";
import { useRouter } from "vue-router";
import { useRoute } from "vue-router";
import { useStore } from "vuex";

export default {
  props: ["options"],
  setup(props, context) {
    const data = reactive({
      input: null,
      select: null,
      value1: null,
      radio: 3,
    });
    //选择科室
    const changeVal = () => {
      if (data.select == null) {
        data.select = "";
      }
      context.emit("changeVal", data.select);
    };
    //点击搜索患者
    const seachys = () => {
      if (data.input == null) {
        data.input = "";
      }
      context.emit("seachys", data.input);
    };
    //选择类型
    const selectType = () => {
      context.emit("selectType", data.radio);
    };
    //选择时间范围
    const selectDate = () => {
      if (data.value1 == null) {
        data.value1 = "";
      }
      context.emit("amentDate", data.value1);
    };
    //重置
    const resetSH = () => {
      data.input = null;
      data.select = null;
      data.value1 = null;
      data.radio = 3;
      context.emit("resetSH");
    };
    return {
      ...toRefs(data),
      changeVal,
      seachys,
      selectDate,
      selectType,
      resetSH,
    };
  },
};
</script>
<style lang="scss" scoped>
.flex {
  display: flex;
}
.utlis {
  @extend .flex;
  width: 100%;
  justify-content: space-between;
  height: 60px;
  align-items: center;
  ::v-deep(.el-date-editor) {
    height: 42px;
    padding: 0 12px;
    margin-right: 20px;
    transform: translateY(2px);
  }
  .selectDate {
    @extend .flex;
    span {
      padding: 8px 36px;
      border: 1px solid #0066ff;
      color: #0066ff;
      cursor: pointer;
      &:nth-child(2) {
        border-right: none;
        border-left: none;
      }
      &:nth-child(1) {
        border-radius: 6px 0 0 6px;
      }
      &:nth-child(3) {
        border-radius: 0px 6px 6px 0px;
      }
    }
    .active {
      background-color: #0066ff;
      color: #fff;
    }
  }
  .el-radio {
    margin-right: 10px;
  }
  .el-input {
    height: 42px;
    width: 240px;
    margin-right: 20px;
    ::v-deep(.el-input__wrapper) {
      padding: 0 12px;
    }
  }
  .el-button {
    height: 42px;
    padding: 0 20px;
    background-color: #0066ff;
  }
}
</style>
<style>
.thead-utils {
  margin-right: 20px;
}
.thead-utils .el-input__wrapper {
  padding: 0 12px;
}
.thead-utils .el-input {
  height: 42px;
}
</style>
